import {createRouter, createWebHistory} from "vue-router";
import {App} from "vue";
import {routes} from "@/router/routes";
import {setupRouterGuard} from "@/router/guard";

export const router = createRouter({
    strict: true,
    scrollBehavior: () => ({left: 0, top: 0}),
    history: createWebHistory(),
    routes: [...routes]
});

const setupRouter = async (app: App) => {
    app.use(router);
    setupRouterGuard(router);
}
export const resetRouter = () => {
    router.clearRoutes()
    routes.forEach(e => router.addRoute(e))
}


export default setupRouter
